package com.zls.job;

import com.zls.pojo.User;
import com.zls.service.UserService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Random;

public class MyJob implements Job {
    @Autowired
    private UserService userService;
    //执行业务逻辑
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("Execute...."+new Date());
        User user=new User();
        Random random=new Random();
        user.setUserName("com.zls"+random.nextInt(1000));
        user.setPassword("1111");
        user.setAge(random.nextInt(100));
        userService.addUser(user);
    }
}
